﻿using System;
using System.Collections.Generic;
using System.Linq; 

namespace NTTDATA.BEENChina.ResultCertification.Split
{
    public class SplitNameResult 
    {
        private static readonly string[] SplitCharacterA = new string[] { " ", "・" };
        private static readonly string[] SplitCharacterB = new string[] { "(", ")" };
        private static readonly string[] CompanysCharacter = new[] { "株", "有", "ゆ", "かぶ","か" };
        


        //private static string[] splitCharacter = new string[] { " ", "・", "(", ")" };

        public static List<string> GetSplitResult(string entryResult)
        {
            List<string> splitReuslt = new List<string>();

            List<string> results = entryResult.Split(SplitCharacterA, StringSplitOptions.None).ToList();
            

            foreach (string result in results)
            {
                string eachResult = result;
                if ( SplitCharacterB.Any(t=> result.Contains(t) ))
                {
                    if (!CompanysCharacter.Any(t => result.Contains(t)))
                    {

                        splitReuslt.AddRange(
                            eachResult.Split(SplitCharacterB, StringSplitOptions.None).ToList());
                    }
                    else
                    {
                        
                        splitReuslt.Add(eachResult );    
                    }

                }
                else
                {

                    splitReuslt.Add( eachResult);
                }

            }

            return splitReuslt.Where(t => !string.IsNullOrEmpty(t)).Where(t => !string.IsNullOrWhiteSpace(t)).Select(t => t.Trim()).ToList();
        }
    }
}
